import 'dart:convert';

import 'package:flutter/material.dart';

class PendingModel {
  String? bedNo;
  String? elderName;
  String? expenseItem;
  String? resultUnit;
  int? resultMode; // == 0 时直接完成执行
  List<PendingInfo>? result;
  PendingModel({
    this.bedNo,
    this.result,
    this.elderName,
    this.expenseItem,
    this.resultUnit,
    this.resultMode,
  });

  factory PendingModel.fromJson(Map<String, dynamic> json) {
    final List? originList = jsonDecode(json['result']);
    List<PendingInfo> protocolList =
        (originList??[]).map((value) => PendingInfo.fromJson(value)).toList();
    return PendingModel(
      result: protocolList,
      bedNo: json['bedNo'],
      elderName: json['elderName'],
      expenseItem: json['expenseItem'],
      resultUnit: json['resultUnit'],
      resultMode: json['resultMode'],
    );
  }
}

class PendingInfo {
  String? value;
  String? rangeTo;
  String? subItem;
  String? rangeFrom;
  String? property;
  TextEditingController? textEditingController;

  PendingInfo({
    this.value,
    this.rangeTo,
    this.subItem,
    this.rangeFrom,
    this.property,
    this.textEditingController,
  });

  PendingInfo.fromJson(Map data) {
    value = data['value'].toString();
    rangeTo = data['rangeTo'].toString();
    subItem = data['subItem'];
    rangeFrom = data['rangeFrom'].toString();
    property = data["property"];
    textEditingController = TextEditingController();
  }
}
